package com.etc.common;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {
    static SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM");
    static SimpleDateFormat sdfymd = new SimpleDateFormat("yyyy-MM-dd");

    public static String toStrfomartYM(Date d) {
        return sdf.format(d);
    }


    public static Date toDatefomartYM(String d) {
        Date d1 = null;
        try {
            d1 = sdf.parse(d);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return d1;
    }

    public static String toStrfomartYMD(Date d) {
        return sdfymd.format(d);
    }


    public static Date toDatefomartYMD(String d) {
        Date d1 = null;
        try {
            d1 = sdfymd.parse(d);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return d1;
    }
}